***********************************
*								  *
* Andrews, Delton, & Kline.       *
* Study 1 Analyses.               * 
*								  *
***********************************

*** Put your path to the repository ***


use Study_1, clear

*generate dummy for contribting any way (risky or certain)
gen anycon = .
	replace anycon = 1 if(certain == 1)
	replace anycon = 1 if(gamble == 1)
	replace anycon = 0 if(defect == 1)

*Figure 4: Percent making risky, certain, or no contirbution at each threshold
graph bar gamble certain defect, over(threshold, label(labsize(med))) ///
	bar(1, color(black)) bar(2, color(gs10) lcolor(black)) ///
	bar(3, color(white) lcolor(black)) text(-.06 50 "Threshold (�)", size(medlarge)) ///
	ytitle("Percentage of Choices", size(large)) ylabel(, labsize(med)) legend( ///
	label(1 "Risky Contribution") label(2 "Certain Contribution") ///
	label(3 "Defection") pos(1) size(medlarge)) 
	
*Do players make more risky contributions at the highest three thresholds?
	gen top_3 = 0 //identify if at top three threshold
	replace top_3 = 1 if(threshold > 90)
ttest gamble, by(top_3)

*Supplemental table 1: predicting defection
reg defect threshold0to1, robust
reg defect threshold0to1 thresholdsquared0to1, robust

*Supplemental table 2: predicting risky contributions
reg gamble threshold0to1 thresholdsquared0to1, robust
	
-- STOP HERE FOR MAIN ANALYSES --







***********************************
*								  *
* Andrews, Delton, & Kline.       *
* Study 2 & 3 Analyses.           * 
*								  *
***********************************

*NOTE: Combined Study_2_and_3.xls only includes data from Study 2 conditions references in the main text
use Study_2_and_3, clear

*Generate dummy variable for making any contribution 
gen anycon = 0
replace anycon = 1 if(gamble == 1)
replace anycon = 1 if(certain == 1)

********************************************************
* Effect of Threshold on Contributions Pre-Information *
********************************************************

*NOTE
*subgroup 1: MTurk 90 own risk/90 beneficiary group risk
*subgroup 2: MTurk 10 own risk/10 beneficiary group risk
*ssubgroup 3: Lab,90 own risk/90 beneficiary group risk

*Do respondents make risky contributions more at the higher threshold?

*Pooled across studies
ttest gamble, by(threshold0to1)

*Within each subgroup
gen gamble_1 = gamble if(subgroup == 1)
gen gamble_2 = gamble if(subgroup == 2)
gen gamble_3 = gamble if(subgroup == 3)

ttest gamble_1, by(threshold0to1) //subgroup 1
ttest gamble_2, by(threshold0to1) //subgroup 2
ttest gamble_3, by(threshold0to1) //subgroup 3

*Figure 5: The percent of subjects making risky contributions
graph bar gamble, over(threshold) ///
	over(subgroup, relabel(1 "90/90" 2 "10/10" 3 "Lab")) ///
	bar(1, fcolor(gs0) lcolor(gs0)) ///
	bar(2, fcolor(gs10) lcolor(gs0)) ///
	legend(order(1 "Risky" 2 "Certain")) ///
	title("Decisions by Threshold") 
	
*Supplemental Table 3: Risky contributions before the opportunity to buy information
reg gamble threshold0to1, robust
reg gamble threshold0to1##i.subgroup risk, robust 

*************************
* Who buys information? *
*************************

*Figure 6: Percent of players buying information based on initial decision
gen ginfo = buyinfo if(gamble == 1) 
gen cinfo = buyinfo if(certain == 1)
gen dinfo = buyinfo if(defect == 1)

graph bar ginfo cinfo dinfo, over(subgroup, relabel(1 "90% Risk on Mturk" 2 "10% Risk on Mturk" ///
	3 "90% Risk in Lab")) ///
	bar(1, color(black)) bar(2, fcolor(white) lcolor(black)) bar(3, lcolor(black)) ///
	ytitle("Proportion Buying Information", size(medlarge)) legend(order(1 "Risky Contribution" ///
	2 "Certain Contribution" 3 "Defect") size(med) ring(1) pos(6) col(3) ///
	region(lpattern(solid) lcolor(gs0))) ylabel(0(0.2)1)

*Do those who contribute buy information more often than those who do not contribute? 
	gen anycon1  = anycon if(subgroup == 1)
	gen anycon2  = anycon if(subgroup == 2)
	gen anycon3  = anycon if(subgroup == 3)

gen buyinfo1 = buyinfo if subgroup == 1
ttest buyinfo1, by(anycon1) //subgroup 1
gen buyinfo2 = buyinfo if subgroup == 2
ttest buyinfo2, by(anycon2) //subgroup 2
gen buyinfo3 = buyinfo if subgroup == 3
ttest buyinfo3, by(anycon3) //subgroup 3

*****************************************************
* What are the effects of information on decisions? *
*****************************************************

*Identify those who initially made the wrong choice
gen pre_wrong80 = 1 if(threshold == 80 & certain == 0)
gen pre_wrong120 = 1 if(threshold == 120 & gamble == 0)

*Identify those who changed from the wrong to the right choice
gen change_right = 0 if pre_wrong80 == 1
replace change_right = 0 if pre_wrong120 == 1
replace change_right = 1 if(change_right == 0 & threshold == 80 & real_certain == 1)
replace change_right = 1 if(change_right == 0 & threshold == 120 & real_gamble == 1)

*Did more players contribute correctly at the 80 token threshold after the 
	*opportunity to buy information? 
	
	*Pooled across subgroups
	gen certain80 = certain if(threshold == 80) 
	gen real_certain80 = real_certain if(threshold == 80)
	signrank real_certain80 = certain80

	*By subgroup
	gen certain801 = certain80 if(subgroup == 1)
	gen real_certain801 = real_certain80 if(subgroup == 1)
	signrank real_certain801 = certain801
	gen certain802 = certain80 if(subgroup == 2)
	gen real_certain802 = real_certain80 if(subgroup == 2)
	signrank real_certain802 = certain802
	gen certain803 = certain80 if(subgroup == 3)
	gen real_certain803 = real_certain80 if(subgroup == 3)
	signrank real_certain803 = certain803

*Did more players contribute correctly at the 120 token threshold after the 
	*opportunity to buy information? 

	*Pooled across subgroups
	gen gamble120 = gamble if(threshold == 120)
	gen real_gamble120 = real_gamble if(threshold == 120)
	signrank real_gamble120 = gamble120

	*By subgroup
	gen gamble1201 = gamble120 if(subgroup == 1)
	gen real_gamble1201 = real_gamble120 if(subgroup == 1)
	signrank real_gamble1201 = gamble1201
	gen gamble1202 = gamble120 if(subgroup == 2)
	gen real_gamble1202 = real_gamble120 if(subgroup == 2)
	signrank real_gamble1202 = gamble1202
	gen gamble1203 = gamble120 if(subgroup == 3)
	gen real_gamble1203 = real_gamble120 if(subgroup == 3)
	signrank real_gamble1203 = gamble1203

*Figure 7: Percent making helpful choice before and after the opportunity to buy info
	*Generate variable for correct choice 
	gen pre_right = 0
	replace pre_right = 1 if(certain80 == 1)
	replace pre_right = 1 if(gamble120 == 1)

	gen post_right = 0
	replace post_right = 1 if(real_certain80 == 1)
	replace post_right = 1 if(real_gamble120 == 1)

graph bar pre_right post_right, over(threshold) ///
	over(subgroup, relabel(1 "90/90" 2 "10/10" 3 "Lab")) ytitle("Helpful Choice") ///
	legend(order(1 "Before Information" 2 "After Information")) ///
	title("The Effect of the Opportunity to Buy Information") ///
	bar(1, fcolor(gs10) lcolor(gs0)) bar(2, fcolor(gs0) lcolor(gs0))
	
-- STOP HERE FOR MAIN ANALYSES --






**************************************
*								     *
* Andrews, Delton, & Kline.          *
* Study 2: Comprehension & Behavior  * 
*								     *
**************************************

use Study_2, clear

*Supplemental Figure 6: Distribution of comprehension scores
hist comp_score, percent xtitle("Comprehension Test Score (Study 2)") color(black)

*Supplemental Figure 7: Proportion contributing anything by comprehension

	*generate dummy variable for contributing anything
	gen give = 1
	replace give = 0 if(defect == 1)

graph bar give, over(comp_score) title("Study 2") b1title("Comprehension Test Scores") ///
	ytitle("Proportion Contributing Anything")
	
*Supplemental Figure 8: Proportion buying information by comprehension
graph bar buyinfo, over(comp_score) title("Study 2") b1title("Comprehension Test Scores") ///
	ytitle("Proportion Buying Information")

*Supplemental Figure 9: Changing to correct and incorrect choice by comprehension
	*Start with wrong choice
	gen pre_wrong = 1 if(buyinfo == 1 & threshold == 80 & certain == 0)
	replace pre_wrong = 1 if(buyinfo == 1 & threshold == 120 & gamble == 0)
	
	*Start with right choice
	gen pre_right = 1 if(buyinfo == 1 & threshold == 80 & certain == 1)
	replace pre_right = 1 if(buyinfo == 1 & threshold == 120 & gamble == 1)

	*End with wrong choice
	gen post_wrong = 1 if(buyinfo == 1 & threshold == 80 & real_certain == 0)
	replace post_wrong = 1 if(buyinfo == 1 & threshold == 120 & real_gamble == 0)

	*End with right choice
	gen post_right = 1 if(buyinfo == 1 & threshold == 80 & real_certain == 1)
	replace post_right = 1 if(buyinfo == 1 & threshold == 120 & real_gamble == 1)

	*buy info when start right, but change to wrong
	gen change_wrong = 0 if(buyinfo == 1)
	replace change_wrong = 1 if(pre_right == 1 & post_wrong == 1)

	*buy infor when start wrong, but change to right
	gen change_right = 0 if(buyinfo == 1)
	replace change_right = 1 if(pre_wrong == 1 & post_right == 1)

graph bar change_right change_wrong, over(comp_score) ///
	bar(1, lcolor(black) color(gs12)) bar(2, color(black)) ///
	text(-.02 50 "Comprehension Test Score") legend( pos(1) ///
	label(1 "Changing to Useful Choice") label(2 "Changing to Less Useful Choice")) ///
	ytitle("Proportion of Respondents")

*Supplemental Table 7: Effect of comprehension on buying information and changing decision
reg buyinfo comp_score threshold01 certain gamble, robust
reg change_right comp_score threshold01, robust
reg change_wrong comp_score threshold01, robust

*Supplemental Figure 10: Marginal effect of threshold on risky contribution over comprehension
gen own_other = own01 * other01

reg real_gamble i.threshold01##c.comp_score, robust
margins, dydx(threshold) at(comp_score = (0(1)5))
marginsplot, recast(scatter) xtitle("Comprehension Test Score") ///
	ytitle("Effect of Increased Threshold on Pr(Risky Contribution)") ///
	yline(0)

*Supplemental Table 8: Risky contribution after buying information
gen score_t_int = comp_score * threshold01
reg real_gamble comp_score threshold01 score_t_int own01 other01 own_other, robust

*Supplemental Figure 11: Defection over own and other group risk
reg defect threshold i.own01##i.other01, robust
margins own01, at(other01 = 0) at(other01 = 1)
marginsplot, yline(0) xlabel( 0 "10%" 1 "90%") xtitle("Own Group Risk") ///
 ytitle("Probability of Defection") title("Effect of Own and Other Group Risk on Defection") ///
 plot( , label("Group 2: 10% Risk" "Group 2: 90% Risk")) ///
 plot1opts(lcolor(dkgreen) mcolor(dkgreen)) ci1opts(acolor(dkgreen)) ///
 plot2opts(lcolor(black) mcolor(black)) ci2opts(acolor(black))
	
-- STOP HERE FOR STUDY 2 SUPPLEMENT --







**************************************
*								     *
* Andrews, Delton, & Kline.          *
* Study 3: Comprehension & Behavior  * 
*								     *
**************************************

use Study_3, clear

*Supplemental Figure 12: Distribution of comprehension scores
hist comp_score, percent xtitle("Comprehension Test Score (Study 3)") color(black)

*Correlating comprehension and contributing	
	gen anycon = 0
	replace anycon = 1 if(certain == 1)
	replace anycon = 1 if(gamble == 1)
pwcorr comp_score anycon, sig

*Supplemental Figure 13: Proportion contributing by comprehension
graph bar anycon, over(comp_score) title("Study 3") b1title("Comprehension Test Scores") ///
	ytitle("Proportion Contributing Anything")
	
*Supplemental Figure 14: Buying information by comprehension
graph bar buyinfo, over(comp_score) title("Study 3") b1title("Comprehension Test Scores") ///
	ytitle("Proportion Buying Information")
	
*Supplemental Figure 15: The proportion changing to more or less useful choice by comprehension
	*Start wrong
	gen pre_wrong = 1 if(buyinfo == 1 & threshold == 80 & certain == 0)
	replace pre_wrong = 1 if(buyinfo == 1 & threshold == 120 & gamble == 0)

	*Start right
	gen pre_right = 1 if(buyinfo == 1 & threshold == 80 & certain == 1)
	replace pre_right = 1 if(buyinfo == 1 & threshold == 120 & gamble == 1)

	*End wrong
	gen post_wrong = 1 if(buyinfo == 1 & threshold == 80 & real_certain == 0)
	replace post_wrong = 1 if(buyinfo == 1 & threshold == 120 & real_gamble == 0)

	*End right
	gen post_right = 1 if(buyinfo == 1 & threshold == 80 & real_certain == 1)
	replace post_right = 1 if(buyinfo == 1 & threshold == 120 & real_gamble == 1)

	*buy info when start right, but change to wrong
	gen change_wrong = 0 if(buyinfo == 1)
	replace change_wrong = 1 if(pre_right == 1 & post_wrong == 1)

	*buy info when start wrong, but change to right
	gen change_right = 0 if(buyinfo == 1)
	replace change_right = 1 if(pre_wrong == 1 & post_right == 1)

graph bar change_right change_wrong, over(comp_score) ///
	bar(1, lcolor(black) color(gs12)) bar(2, color(black)) ///
	text(-.04 50 "Comprehension Test Score") legend( pos(1) ///
	label(1 "Changing to Useful Choice") label(2 "Changing to Less Useful Choice")) ///
	ytitle("Proportion of Respondents")
	
*Supplemental Table 9
	gen threshold01 = 0 if(threshold == 80)
	replace threshold01 = 1 if(threshold == 120)
reg buyinfo comp_score threshold01 certain gamble, robust
reg change_right comp_score threshold01, robust
reg change_wrong comp_score threshold01, robust

*Supplemental Figure 16: Effect of treatment by comprehension
	gen comp_score_factor = comp_score * 4
reg real_gamble i.threshold01##i.comp_score_factor, robust
margins, dydx(threshold) at(comp_score_factor = (0(1)4))
marginsplot, recast(scatter) xtitle("Comprehension Test Score") ///
	ytitle("Effect of Increased Threshold on Pr(Risky Contribution)") ///
	title("Study 3") yline(0)




